package com.ruoyi.bussiness.controller;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.bussiness.domain.CcyParsePlan;
import com.ruoyi.bussiness.service.ICcyParsePlanService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 方案分析Controller
 * 
 * @author wzy
 * @date 2025-10-19
 */
@RestController
@RequestMapping("/bussiness/plan")
public class CcyParsePlanController extends BaseController
{
    @Autowired
    private ICcyParsePlanService ccyParsePlanService;

    /**
     * 查询方案分析列表
     */
    @PreAuthorize("@ss.hasPermi('bussiness:plan:list')")
    @GetMapping("/list")
    public TableDataInfo list(CcyParsePlan ccyParsePlan)
    {
        startPage();
        List<CcyParsePlan> list = ccyParsePlanService.selectCcyParsePlanList(ccyParsePlan);
        return getDataTable(list);
    }

    /**
     * 导出方案分析列表
     */
    @PreAuthorize("@ss.hasPermi('bussiness:plan:export')")
    @Log(title = "方案分析", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CcyParsePlan ccyParsePlan)
    {
        List<CcyParsePlan> list = ccyParsePlanService.selectCcyParsePlanList(ccyParsePlan);
        ExcelUtil<CcyParsePlan> util = new ExcelUtil<CcyParsePlan>(CcyParsePlan.class);
        util.exportExcel(response, list, "方案分析数据");
    }

    /**
     * 获取方案分析详细信息
     */
    @PreAuthorize("@ss.hasPermi('bussiness:plan:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(ccyParsePlanService.selectCcyParsePlanById(id));
    }

    /**
     * 新增方案分析
     */
    @PreAuthorize("@ss.hasPermi('bussiness:plan:add')")
    @Log(title = "方案分析", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CcyParsePlan ccyParsePlan)
    {
        return toAjax(ccyParsePlanService.insertCcyParsePlan(ccyParsePlan));
    }

    /**
     * 修改方案分析
     */
    @PreAuthorize("@ss.hasPermi('bussiness:plan:edit')")
    @Log(title = "方案分析", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CcyParsePlan ccyParsePlan)
    {
        return toAjax(ccyParsePlanService.updateCcyParsePlan(ccyParsePlan));
    }

    /**
     * 删除方案分析
     */
    @PreAuthorize("@ss.hasPermi('bussiness:plan:remove')")
    @Log(title = "方案分析", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ccyParsePlanService.deleteCcyParsePlanByIds(ids));
    }
}
